#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <iostream>
#include "udp_server.hpp"
#include "socket_config.hpp"


socket_config config;
udp_server server(config);

void sig_handler(int signum){
    vector<unique_ptr<udp_thread> > *pv= server.get_threads();
    vector<unique_ptr<udp_thread> > ::iterator item;
    int count = 0;
    for(item = pv->begin(); item != pv->end(); ++item)
    {
        count += item->get()->iCount.load();

    }
    printf("handler %d\n",count);
}

int main() {


    // Register signal handler

    if (signal(SIGUSR1,sig_handler) < 0) {
        perror ("signal");
        return 1;
    }



    cout << server.init(thread::hardware_concurrency()) << endl;

    return 0;
}
